﻿Public Class Result


    ''' <summary>
    ''' Export item resource to string
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function export(ByVal listItemWithAlias As DataTable) As String
        Dim resultDict As New Dictionary(Of String, String)
        Dim result, itemName, itemAlias As String

        result = ""
        'copy to final dictionary
        For i As Int16 = 0 To listItemWithAlias.Rows.Count - 1 Step 1
            itemName = listItemWithAlias.Rows(i).Item("ItemName")
            If (Not resultDict.ContainsKey(itemName)) And itemName <> "Dupplicate Keys" Then
                itemAlias = listItemWithAlias.Rows(i).Item("Alias")
                resultDict.Add(itemName, itemAlias)
            End If
        Next

        'Convert to string
        For Each key As String In resultDict.Keys
            result = result & String.Format(config.Item(RAW_ENTRY), key, resultDict.Item(key)) & vbNewLine
        Next key
        Return result
    End Function

    Private Sub Result_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tbxResult.Text = export(mainForm.returnDt)
    End Sub
End Class